from pyecharts import options as opts
from pyecharts.charts import Tree
from pyecharts.globals import ThemeType
from docx import Document
doc=Document('仍共振常见应用场景.docx')
data=[]
title2=[]
title2_num,title2_temp=0,0
for para in doc.paragraphs:
    level=para.style.name
    if level=='Heading 1':
        dict={}
        dict['name']=para.text
        data.append(dict)
    elif level=='Heading 2':
        title2_num=title2_num+1
        dict={}
        dict['name']=para.text.spliit('. ')[1]
        title2.append(dict)
        data[0]['children']=title2
    elif level=='Heading 3':
        if title2_temp !=title2_num:
            title2_temp =title2_num
            title3=[]
        dict={}
        dict['name']=para.text.split()[1]
        title3.append(dict)
        data[0]['children'][title2_num-1]['children']=title3
tree=Tree(init_opts=opts.InitOpts(
    width='800px',height='900px',
    theme=ThemeType.LIGHT,page_title='树状图'
))
tree.add(series_name=''.)